package com.mimosa.common.system.dic;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mimosa.common.dao.HibernateDao;
import com.mimosa.common.service.CommonService;
import com.mimosa.common.system.user.UserContext;

/**
 * 字典信息设置的DAO类
 * 
 * @filename DicSettingEntityService.java
 * @author ggeagle
 * @date 2013-6-25 下午5:48:16
 */
@Service
@Transactional
public class DicSettingEntityService extends CommonService<TDicSettingEntity, String> {
	@Resource
	private TDicSettingEntityDao dicSettingEntityDao;

	@Resource
	private UserContext userContext;

	@Override
	protected HibernateDao<TDicSettingEntity, String> getHibernateDao() {
		return this.dicSettingEntityDao;
	}

	/**
	 * 根据类型获取所有的字典实体
	 * 
	 * @param rwhat
	 * @return
	 */
	public List<TDicSettingEntity> getAllByClassType(String rwhat) {
		return dicSettingEntityDao.getAllByClassType(rwhat);
	}

	@Override
	public void saveEntity(TDicSettingEntity entity) {
		entity.setLastUpdateTime(new Date());
		entity.setLastUpdateUserId(userContext.currentUserId());
		super.saveEntity(entity);
	}

	@Override
	public void saveEntityList(List<TDicSettingEntity> entityList) {
		for (TDicSettingEntity entity : entityList) {
			this.saveEntity(entity);
		}
	}

	@Override
	public void deleteEntityList(String[] ids) {
		super.deleteEntityList(ids);
	}
}